package sz.szsmk.citizencard.ui.newversion.activity.presenter

import sz.szsmk.citizencard.DaggerApplication
import sz.szsmk.citizencard.model.network.bean.request.AccessTokenRequest
import sz.szsmk.citizencard.model.network.bean.request.CouponReq
import sz.szsmk.citizencard.model.network.bean.response.BaseBean
import sz.szsmk.citizencard.model.network.bean.response.CouponListBean
import sz.szsmk.citizencard.mvp.dzsmkpresenter.AppBasePresenter
import sz.szsmk.citizencard.retrofitrxjava.newversion.ApiCallback
import sz.szsmk.citizencard.retrofitrxjava.newversion.HttpDateSource
import sz.szsmk.citizencard.smkretrofit.NetworkDateSource
import sz.szsmk.citizencard.ui.newversion.fragment.view.ICouponUsedMvpView
import sz.szsmk.citizencard.util.ACache
import javax.inject.Inject

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/11/15 9:52
 * description:
 */
class CouponUsedPresenter@Inject constructor(var httpDateSourceNotUse: NetworkDateSource)
    : AppBasePresenter<ICouponUsedMvpView>() {


    fun getUserCoupons(){
        var couponReq = CouponReq()
        //status (integer): 优惠券有效性（0 已失效，1 未使用，2 已使用） ,
//        couponReq.status = 1
//        couponReq.access_token = ACache.get(DaggerApplication.getIns()).getAsString("access_token")
        couponReq.access_token = "3167d98d9342633ced87c0f7a697961d"
        couponReq.couponId = "5"
        couponReq.userId = "1750229"
        addSubscription(HttpDateSource.createApi()?.getUserCoupons(couponReq), object : ApiCallback<CouponListBean?> {
            override fun onSuccess(response: CouponListBean?) {
                response?.let {
                    mvpView.getCouponCountSuccess(it)
                }
            }

            override fun onFailure(model: BaseBean?, e: Throwable?) {
                model?.let { mvpView.onFail(it) }
            }
        })
    }


}